Sane docker file optimized for quick rebuilds

Andrew Curioso 10 years ago
parent
commit
f292fc089c
1 changed files with 56 additions and 0 deletions
  1. 56 0
      Dockerfile

+ 56 - 0
Dockerfile

@@ -0,0 +1,56 @@
1
+FROM ubuntu
2
+# MAINTAINER Someone <someone@example.com>
3
+
4
+# Update package list
5
+RUN apt-get update
6
+
7
+# Set environmental variables
8
+ENV HOME /root
9
+ENV RBENV_ROOT $HOME/.rbenv
10
+ENV RUBY_VERSION 1.9.3-p545
11
+ENV RUBYGEMS_VERSION 2.2.2
12
+ENV PATH $HOME/.rbenv/shims:$HOME/.rbenv/bin:$RBENV_ROOT/versions/$RUBY_VERSION/bin:$PATH
13
+
14
+# Install OS packages
15
+RUN apt-get install -y build-essential curl zlib1g-dev libreadline-dev libssl-dev libcurl4-openssl-dev git libmysqlclient-dev
16
+
17
+RUN git clone https://github.com/sstephenson/rbenv.git $HOME/.rbenv
18
+RUN git clone https://github.com/sstephenson/ruby-build.git $HOME/.rbenv/plugins/ruby-build
19
+
20
+# install & set global ruby version
21
+RUN rbenv install $RUBY_VERSION
22
+RUN rbenv global $RUBY_VERSION
23
+
24
+WORKDIR /usr/local/src
25
+
26
+RUN curl -O http://production.cf.rubygems.org/rubygems/rubygems-$RUBYGEMS_VERSION.tgz
27
+RUN tar -xvf rubygems-$RUBYGEMS_VERSION.tgz
28
+RUN cd rubygems-$RUBYGEMS_VERSION ; ruby setup.rb
29
+
30
+RUN gem install bundle
31
+
32
+RUN mkdir huginn
33
+WORKDIR huginn
34
+
35
+# Add Gemfiles and run bundle ahead of time
36
+# This way bundle does not have to rerun unless the Gemfile changes
37
+# It drastically speeds up rebuilds
38
+ADD Gemfile /usr/local/src/huginn/
39
+ADD Procfile /usr/local/src/huginn/
40
+ADD Gemfile.lock /usr/local/src/huginn/
41
+RUN bundle
42
+
43
+# Now add the rest of the source
44
+ADD . /usr/local/src/huginn/
45
+RUN rm -rf /usr/local/src/huginn/.env
46
+
47
+# Add the environmental variables this way so that the -e option can override them
48
+ENV DATABASE_HOST db
49
+ENV DATABASE_NAME huginn
50
+ENV DATABASE_USERNAME huginn
51
+
52
+# Expose the Rails port to the rest of the world
53
+EXPOSE 3000
54
+
55
+# Default command - optimized for upgradability
56
+CMD ["foreman", "start"]